package com.baselibrary.libs.design_mode.Observable_demo.ui;

import android.app.Activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.baselibrary.libs.R;
import com.baselibrary.libs.design_mode.Observable_demo.Appc;
import com.baselibrary.libs.design_mode.Observable_demo.Observer.P_B;

public class MainActivity2 extends Activity implements View.OnClickListener {

    private P_B mP_b;
    private EditText edit;
    private Button bt_03;
    private RelativeLayout activity_main2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        initView();

    }

    private void initView() {
        edit = (EditText) findViewById(R.id.edit_02);
        bt_03 = (Button) findViewById(R.id.bt_03_02);

        bt_03.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int i = v.getId();
        if (i == R.id.bt_03_02) {
            Appc.sGetData().setData(edit.getText().toString());

            Appc.sGetData().notifyObservers("我这个修改来自Man2界面");
        }
    }

    private void submit() {
        // validate
        String editString = edit.getText().toString().trim();
        if (TextUtils.isEmpty(editString)) {
            Toast.makeText(this, "输入修改内容", Toast.LENGTH_SHORT).show();
            return;
        }

        // TODO validate success, do something


    }
}
